﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConceptsFramework.Containers.Generic;

namespace PatternExplorer.DerivedConcepts
{
    /// <summary>
    /// GenericTypeSummary<T> is a generic type which parameter is also a TypeSummary context
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class SingleGenericTypeSummary : TypeSummary
    {
        private BindableConceptContainer<SingleGenericParameterSummary> GenericVariations;

        public SingleGenericTypeSummary()
        {
            GenericVariations = new BindableConceptContainer<SingleGenericParameterSummary>();
            GenericVariations.ConceptKeyRetriever = a => a.GenericArgumentType;
            GenericVariations.ParentConcept = this;
        }

        /// <summary>
        /// Defines the generic argument type declared in the generic class definition
        /// </summary>
        public string BaseGenericArgumentType
        {
            get;
            set;
        }

        public SingleGenericParameterSummary GetGenericTypeVariation(string strGenericType)
        {
            
            SingleGenericParameterSummary aSingleGenericTypeSummary = new SingleGenericParameterSummary();
            aSingleGenericTypeSummary.BaseGenericArgumentType = this.BaseGenericArgumentType;
            aSingleGenericTypeSummary.GenericArgumentType = strGenericType;
            if (!GenericVariations.Contains(strGenericType))
            {
                GenericVariations.Add(aSingleGenericTypeSummary);
                
            }


            return GenericVariations.Container[strGenericType];
        }

    }
}
